/**
 * Created by dfsj16111702 on 2016/12/27.
 */
angular.module('mamApp').controller('albumPlayController', ['$scope', 'AlbumPlayManager', '$state','api','paramsManager',
    function ($scope, AlbumPlayManager, $state,api,paramsManager) {
        $scope.search = {
            pageNo: $state.params.pageNo || 1,
            pageSize: $state.params.pageSize || 10,
            key: $state.params.key || "",
            value: $state.params.value || '',
            "X-Auth-Token":$scope.userInfo.token
        };

        $scope.paginationConf = {
            currentPage: $state.params.pageNo || 1,
            itemsPerPage: $state.params.pageSize || 10,
            pagesLength: 9,
            search: 0,
            onChange: function () {
                $scope.search.pageNo = this.currentPage;
                $scope.search.pageSize = this.itemsPerPage;
                $state.go($state.current.name, $scope.search)
            }
        };

        $scope.selectTerms = [
            {key: "", value: "选择条件"},
            {key: "albumId", value: "专辑_ID"},
            {key: "albumName",value: "专辑名称"}
        ];

        $scope.downHref=api+"/cp/stat/play/albums/excel"+paramsManager.query($scope.search);

        $scope.findData=function(){
            AlbumPlayManager.albumPlay([$scope.search.pageNo, $scope.search.pageSize], $scope.search).then(function (result) {
                $scope.albumPlayList = result.data.pageList;
                $scope.paginationConf.totalItems = result.data.total;
            })
        }

        AlbumPlayManager.albumPlay([$scope.search.pageNo, $scope.search.pageSize], $scope.search).then(function (result) {
            $scope.albumPlayList = result.data.pageList;
            $scope.paginationConf.totalItems = result.data.total;
        });

        $scope.keyup=function (e,keyword) {

            if(e.key=="Enter"){
                $scope.search.pageNo=1;
                $scope.search.keyword = keyword;
                $scope.search.reviewStatus = $scope.search.reviewStatus == "null" ? null : $scope.search.reviewStatus;
                $state.go($state.current.name, $scope.search);
            }
        }


    }]);
